package com.zxm.ex.user.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zxm.ex.common.exception.BackendException;
import com.zxm.ex.common.vo.BasePage;
import com.zxm.ex.common.vo.BaseResultVo;
import com.zxm.ex.user.service.IUserService;
import com.zxm.ex.user.vo.MoocUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/filmsuser")
public class BackendUserController {

    @Autowired
    private IUserService iUserService;


    /**
     * 根据用户编号查询用户信息
     * @param userId
     * @return
     */
    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
    public BaseResultVo getUserInfo(@PathVariable("userId") String userId) throws BackendException {
        System.out.println(userId);
        MoocUserVo userInfo = iUserService.getUserInfo(userId);
        return BaseResultVo.success(userInfo);
    }

    /**
     * 用户分页数据查询
     * @param basePage
     * @return
     * @throws BackendException
     */
    @RequestMapping(value = "/getuserlist", method = RequestMethod.GET)
    public BaseResultVo getUserList(BasePage basePage) throws BackendException {
        IPage<MoocUserVo> iPage=iUserService.getUserList(basePage);
        return BaseResultVo.success(iPage);
    }
}
